# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=lsof
pkgver=4.99.3
pkgrel=0
pkgdesc="LiSt Open Files"
url="https://github.com/lsof-org/lsof"
arch="all"
license="custom"
subpackages="$pkgname-doc"
makedepends="bash linux-headers perl"
source="https://github.com/lsof-org/lsof/archive/$pkgver/lsof-$pkgver.tar.gz
	hassecurity.patch
	"

prepare() {
	default_prepare

	# This test is skipped on other architectures where unshare
	# returns "Operation not permitted", but on ppc64le unshare
	# returns "Function not implemented" causing a fail instead
	case "$CARCH" in
	ppc64le)
		rm -v lib/dialects/linux/tests/case-20-mmap.bash
		;;
	esac
}

build() {
	./Configure -n linux
	make
}

check() {
	(cd tests && ./Add2TestDB)
	make check
}

package() {
	install -Dm0755 lsof -t "$pkgdir"/usr/bin/
	install -Dm0644 Lsof.8 "$pkgdir"/usr/share/man/man8/lsof.8
	install -Dm0644 COPYING -t "$pkgdir"/usr/share/licenses/$pkgname/
}

sha512sums="
eed9cddecf93cf55e8106a0409d254feca8c5c40792d7dad4b34cbe7c9caec00b7a7b9526465362bf3448efef219fd6e309051455d20fd0945391e915a43bc93  lsof-4.99.3.tar.gz
379c24df3bcad88bd35c2d9331064312e9faa0e6426479b3e3d3edd377860007ba3af2a0b4b0b998f0146bfd7d067dc4ee7d6f32a6f5e352afc875f6298ab1c2  hassecurity.patch
"
